﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model_SSResourceManager;
using System.Threading.Tasks;

namespace Presenter_SSResourceManager
{
    public class PresenterManageQueues
    {
        private readonly ModelsManager _mModel;
        private readonly IViewManageQueues _viewManageQueues;

        public PresenterManageQueues(IViewManageQueues view)
        {
            this._viewManageQueues = view;
            _mModel = ModelInstanse.Get();

        }

        public void LoadData()
        {
            IEnumerable<ShowQueue> queues = _mModel.queueModel
                .GetAll(true)
                .Select(queue => new ShowQueue()
                    {
                        Id = queue.Id,
                        ResourceName = _mModel.resourceModel.GetResourceName(queue.IdResource),
                        UserName = _mModel.userModel.GetUserName(queue.IdUser),
                        StartTime = queue.StartTime,
                        FinishTime = queue.FinishTime
                    });
            _viewManageQueues.SetDataForQueues(queues);
        }

        public void DeleteResourse()
        {
            throw new NotImplementedException();
        }
    }

    public class ShowQueue
    {
        public Guid Id { get; set; }
        public string ResourceName { get; set; }
        public string UserName { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime FinishTime { get; set; }
    }
}
